<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>jQuery Form labels Plugin</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript"></script>
        <script src="Scripts/jquery.formLabels1.0.js" type="text/javascript"></script>
        <script src="Scripts/ServletAddress.js" type="text/javascript"></script>
        <script type="text/javascript">		
		var  session=null;
		$(document).ready(function(){
			$("#exit").click(function(){
				jQuery(window.parent.document).find("#login").fadeOut(1500);	
			});
			
			$("#submit").click(function(){				
				var userName=$("#email-input").attr("value");
				var psw=$("#password-input").attr("value");
				
				$.post(ServletAddress+LoginAddress+"UserName="+userName+"&PassWd="+psw,function(result){ 					
						
					//判断是否成功，如果成功，关闭对话框；不成功，继续输入
					//alert(result);	
					if(result==-1)
					{
						alert("登陆失败，请详细核对用户名和密码！");
					}	
					else
					{
						//存入session
						jQuery(window.parent.document).find("#login").fadeOut(1500);	
						session=result;
						//alert(session);
					}						
				});	
			});
		});
			/*
            $(function(){ 
                $.fn.formLabels();
                $("form").submit(function(){
                    var formVal = $("form").serialize();
                    parent.$("#default div.results").html(formVal);
                    return false
                });
            });	*/			
        </script>
        <link href="CSS/loginStyle.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="cont" class="group" style="position:absolute; left:0px; top:0px;">
    	<form method="post" action="" id="login">
        	<h3>用户登陆</h3>
                <div class="field"><input type="email" name="email" title="用户名" id="email-input" /></div>
                <div class="field"><input type="password" name="password" title="密码" id="password-input" /></div>			
				<div id="exit" class="submit" style="position:absolute;left:30px;"><button type="button">退出</button></div> 
				<div id="submit" class="submit"><button type="submit">登陆</button></div>    	
				
        </form>
      </div>
</body>
</html>
